
var Tag = new Object();
//alert(document.documentElement.clientHeight);
//var IFRAME_HEIGHT = document.body.scrollHeight - 300;
var doc = document;
var height = 100;
if (parent != top) {
	doc = parent.parent.document;
	height = 180;
}
var IFRAME_HEIGHT = doc.documentElement.clientHeight - height;
Tag.selectTag = function (moduleId, tagPage) {
	// tag
	var tag = document.getElementById("tags").getElementsByTagName("li");
	for (i = 0; i < tag.length; i++) {
		tag[i].className = "";
	}
	tagPage.parentNode.className = "selectTag";
	// iframe
	var iframe = document.getElementById("tagContent").getElementsByTagName("iframe");
	for (i = 0; i < iframe.length; i++) {
		iframe[i].style.display = "none";
	}
	document.getElementById("iframe_" + moduleId).style.display = "block";
};
Tag.addTag = function (moduleId, moduleName, url, path) {
	if (document.getElementById(moduleId)) {
		Tag.selectTag(moduleId, document.getElementById(moduleId).childNodes[0]);
		return;
	}
	var li = document.createElement("li");
	li.innerHTML = "<span onclick=\"Tag.selectTag('" + moduleId + "',this)\">" + moduleName + "</span><a href=\"javascript:void(0)\" onclick=\"Tag.removeTag('" + moduleId + "')\"><img src=\"" + (path != null ? path : "") + "images/close.gif\" border=\"0\"/></a>";
	li.id = moduleId;
	document.getElementById("tags").appendChild(li);
	var iframe = document.createElement("iframe");
	iframe.id = "iframe_" + moduleId;
	iframe.style.width = "100%";
	iframe.style.height = IFRAME_HEIGHT + "px";
	iframe.src = url;
	iframe.setAttribute("frameborder", "0", 0);
	document.getElementById("tagContent").appendChild(iframe);
	Tag.selectTag(li.id, li.childNodes[0]);
};
Tag.addSelectTag = function (moduleId, url) {
	if (document.getElementById("iframe_" + moduleId)) {
		Tag.selectTag(moduleId, document.getElementById(moduleId).childNodes[0]);
		return;
	}
	var li = document.getElementById(moduleId);
	var iframe = document.createElement("iframe");
	iframe.id = "iframe_" + moduleId;
	iframe.style.width = "100%";
	iframe.style.height = IFRAME_HEIGHT + "px";
	iframe.src = url;
	iframe.setAttribute("frameborder", "0", 0);
	document.getElementById("tagContent").appendChild(iframe);
	Tag.selectTag(li.id, li.childNodes[0]);
};
Tag.removeTag = function (moduleId) {
	var tag = document.getElementById("tags").getElementsByTagName("li");
	for (i = 1; i < tag.length; i++) {
		if (tag[i].id == moduleId) {
			var tags = document.getElementById("tags");
			tags.removeChild(tag[i]);
			Tag.selectTag(tag[i - 1].id, tag[i - 1].childNodes[0]);
			document.getElementById("tagContent").removeChild(document.getElementById("iframe_" + moduleId));
			break;
		}
	}
};

